using System;
using System.ServiceModel;
using WcfService;

namespace WcfServiceHost
{
	internal class Program
	{
		private static void Main(string[] args)
		{
			try
			{
				StartService();
				Console.WriteLine("Service is running...");
				Console.WriteLine("Press key to end...");
				Console.ReadLine();
				StopService();
			}
			catch (Exception ex)
			{
				Console.Write("The following exception was caught: " + Environment.NewLine + ex);
			}
		}

		internal static ServiceHost myServiceHost = null;

		internal static void StartService()
		{
			Uri baseAddress = new Uri("http://localhost:8080/PersonService");
			myServiceHost = new ServiceHost(typeof (PersonService), baseAddress);
			myServiceHost.Open();
		}

		internal static void StopService()
		{
			if (myServiceHost.State != CommunicationState.Closed)
				myServiceHost.Close();
		}
	}
}